package com.yequan.work;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author yequan
 * @date 2021/04/06 10:24
 **/
public class MyJsonTest {

    public static void main(String[] args) {
//        seatNum();
//        mapPutNon();
        ride();
    }

    public static void ride(){
        String rideInfo = "{\"createTime\":1628643723000,\"driverReceivedPrice\":143.95,\"driverUserId\":17141189,\"extra\":\"{\\\"multi_price\\\":\\\"161.3\\\",\\\"available_start_time_from\\\":\\\"20210825075000\\\",\\\"multi_price_one\\\":\\\"161.3\\\",\\\"end_baidu_area_name\\\":\\\"历城区\\\",\\\"base_distance\\\":\\\"0.0\\\",\\\"multi_accept_price_one\\\":\\\"161.3\\\",\\\"available_start_time_to\\\":\\\"20210825102000\\\",\\\"transfer_money\\\":\\\"700.0\\\",\\\"single_price\\\":\\\"436.4\\\",\\\"distance_money\\\":\\\"15430.0\\\",\\\"multi_ride_price\\\":\\\"161.3\\\",\\\"person_num_detail\\\":\\\"{\\\\\\\"adult\\\\\\\":1,\\\\\\\"child\\\\\\\":0,\\\\\\\"junior\\\\\\\":0,\\\\\\\"baby\\\\\\\":0}\\\",\\\"ride_city\\\":236,\\\"multi_save_price\\\":0.0,\\\"serve_fee_bearer\\\":\\\"0\\\",\\\"mix\\\":1,\\\"multi_accept_price\\\":\\\"161.3\\\",\\\"single_price_one\\\":\\\"436.4\\\"}\",\"id\":844127057439883527,\"initiatorComment\":\"一件行李，需用后备箱；已接种疫苗；准时出发；\",\"initiatorTripId\":24,\"initiatorType\":\"passenger\",\"initiatorUserId\":252851555,\"parentRideId\":null,\"personNum\":1,\"planStartTime\":1629853800000,\"price\":161.30,\"replyTime\":1628665390000,\"rideType\":7,\"status\":\"replied\",\"suggestPrice\":161.30,\"timeType\":0,\"updateTime\":1628679242000}";
        Ride ride = JsonMapper.json2Bean(rideInfo, Ride.class);
        System.out.println(ride.toString());
    }

    public static void mapPutNon() {
        String json="{\"multi_price\":\"244.0\",\"available_start_time_from\":\"20210828115500\",\"multi_price_one\":\"244.0\",\"start_baidu_area_name\":\"南海区\",\"end_baidu_area_name\":\"麻章区\",\"base_distance\":\"0.0\",\"multi_accept_price_one\":\"244.0\",\"available_start_time_to\":\"20210828121000\",\"transfer_money\":\"900.0\",\"single_price\":\"716.0\",\"distance_money\":\"23500.0\",\"multi_ride_price\":\"244.0\",\"person_num_detail\":\"{\\\"adult\\\":1,\\\"child\\\":0,\\\"baby\\\":0,\\\"junior\\\":0}\",\"ride_city\":95,\"multi_save_price\":0.0,\"serve_fee_bearer\":\"0\",\"mix\":1,\"multi_accept_price\":\"244.0\",\"single_price_one\":\"716.0\"}";
        ReplyMap replyMap = new ReplyMap();
        List<Integer> nums = new ArrayList<>();
        nums.add(1);
        nums.add(2);
        replyMap.put("a", nums);
        System.out.println(replyMap.toJson());
        replyMap.put("a", null);
        System.out.println(replyMap.toJson());
    }

    private static void seatNum() {
        String json = "{\"allVerified\":3,\"bigCarphotourl\":\"http://www-ecs.didapinche.com/pics//g/2015081255cabc383abcf.jpg\",\"car_identification_status\":3,\"car_register_date\":\"2018-10-01\",\"carcolor\":1,\"carphotourl\":\"http://www-ecs.didapinche.com/pics//g/2015081255cabc383abcf.jpg\",\"carplate\":\"京QeYuSt\",\"cartype\":\"932\",\"cartypelogo\":\"http://www-ecs.didapinche.com/pics/g/car/dazhong.png\",\"cartypename\":\"大众Cross Coupe\",\"certifyOpTime\":1614115402000,\"cid\":-1,\"drilicuploadtime\":\"20181231225807\",\"driverlicensephotourl\":\"http://www-ecs.didapinche.com/pics//g/driving_licence.png\",\"has_certify_car\":1,\"have_idcard_back_photo\":3,\"have_idcard_photo\":3,\"havecarphoto\":3,\"havedriverlicensephoto\":3,\"havelicensephoto\":3,\"idcard_back_photo_url\":\"http://www-ecs.didapinche.com/pics//g/idcard_back.png\",\"idcard_no\":\"110***********9262\",\"idcard_photo_url\":\"http://www-ecs.didapinche.com/pics//g/idcard_front.png\",\"licence_id_no\":\"110***********9262\",\"license_expire_date\":\"2026-02-23\",\"licenseissuedate\":\"2016-02-26\",\"licensephotourl\":\"http://www-ecs.didapinche.com/pics//g/car_licence.png\",\"new_energy\":1,\"real_name\":\"A*I\",\"rep_driver_lic_enable\":0,\"seat_num\":4,\"security_identify_time\":\"20210224052322\",\"verifyWaterMarkerUrl\":\"http://www-ecs.didapinche.com/pics//g/driver_mask.png\"}";
        Map<String, Object> map = JsonMapper.json2Map(json);
        Object seat_num = map.get("seat_num");
        System.out.println((int) seat_num);
    }

}
